package com.scheudler.demo.quartz;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @author dongqun
 * @version 1.0
 * @description 类的功能描述
 * @date 2019/9/24 14:21
 */
@Component("TaskScheduler1")
public class TaskScheduler implements CommandLineRunner {
    @Autowired
    private TaskService taskService;

    @Override
    public void run(String... args) throws Exception {
        System.out.println("调度任务开始");
        ScheduleJob job = new ScheduleJob();
        job.setJobName("我的定时任务");
        job.setCronExpression("00 * * * * ?");
        job.setJobTask("小王，你去炸掉那个碉堡");
        taskService.execute(job);

        System.out.println("调度任务结束");
    }
}
